layui.use(['form', 'jquery', 'layer', 'table', 'laydate', 'laypage'], function() {
	var form = layui.form;
	var $ = layui.$;
	var table = layui.table;
	var layer = layui.layer;
	var laydate = layui.laydate;
	var laypage = layui.laypage;
	var upload = layui.upload;

	var table_filter = 'pikuanlog_list',
		where_json = {
			_o: 'id',
			_b: 'desc'
		},
		form_filter = 'pikuanlog_search_form';
	// 渲染表格
	if (load_data === true) {
		table.render({
			elem: '#' + table_filter,
			id: table_filter,
			url: pikuanlog_list_url,
			method: 'post',
			height: 'full-200',
			where: {
				_o: 'id',
				_b: 'desc'
			},
			cols: [pikuanlog_cols],
			page: {
				layout: ['count', 'first', 'prev', 'page', 'next', 'last', 'skip'],
				limit: 30,
				theme: '#393d49',
				groups: 8
			},
			autoSort: false,
			toolbar: false,
			initSort: {
				field: 'id',
				type: 'desc'
			}
		});
	}


	form.render();

	// 表单input 查询
	$('form[lay-filter="' + form_filter + '"]').on('input propertychange', 'input[type="text"]', function() {
		if ($(this).prop('comStart')) return;
		var value = $(this).val();
		var name = $(this).attr('name');
		where_json[name] = value;
	}).on('compositionstart', 'input[type="text"]', function() {
		$(this).prop('comStart', true);
	}).on('compositionend', 'input[type="text"]', function() {
		$(this).prop('comStart', false);
		$(this).trigger('input');
	});

	form.on('select', function(data) {
		where_json[data.elem.attributes['lay-filter'].value] = data.value;
	})



	form.on('submit(pikuanlog_search_form)', function(data) {
		layer.load();
		table.reload(table_filter, {
			where: where_json,
			page: {
				curr: 1
			},
			done: function(res, curr, count) {
				layer.closeAll();
			}
		});
		return false
	})

})